package com.kzj.mls.recyclerCard.cardView;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;

import com.ab.util.AbViewUtil;
import com.kzj.mls.R;
import com.kzj.mls.activity.WebActivity;
import com.kzj.mls.global.App;
import com.kzj.mls.global.Constant;
import com.kzj.mls.recyclerCard.basic.CardItemView;
import com.kzj.mls.recyclerCard.card.fragmentMain.DirectoryCard;

/**
 * Created by xyg on 2015/10/26.
 */
public class DirectoryCardView extends CardItemView<DirectoryCard> {

    private Context context;
    private ImageView imageView_icon;
    /*private TextView textView_title;*/

    public DirectoryCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public DirectoryCardView(Context context) {
        super(context);
        this.context = context;
    }

    public DirectoryCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final DirectoryCard card) {
        super.build(card);
        imageView_icon = (ImageView) findViewById(R.id.imageView_icon);
        /* textView_title = (TextView) findViewById(R.id.textView_title);*/

    /*    if (card.getDirectoryBean().getBackcColor()>0)
        {
            this.setBackgroundResource(card.getDirectoryBean().getBackcColor());
        }else
        {
            this.setBackgroundResource(R.drawable.shape_green_7ee1cb);
        }*/
        App.imageLoader.displayImage(card.getIndexServiceBean().getImg(), imageView_icon);
      //  textView_title.setText(card.getDirectoryBean().getTitle());
        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getContext(), WebActivity.class);
                String url= Constant.getHtml5UrlFotParameter(Constant.HTML5.Html5_serviceDetail,card.getIndexServiceBean().getId()+"",App.getInstance().getCity(),App.getInstance().getLongitude(),App.getInstance().getLatitude(),"2");
                intent.putExtra(WebActivity.Title,"服务详情");
                intent.putExtra(WebActivity.WebUrl,url);

                ((Activity)getContext()).startActivity(intent);

            }
        });
        AbViewUtil.scaleView(imageView_icon);
    //    AbViewUtil.scaleView(textView_title);
        AbViewUtil.scaleView(this);
        setNeedScale(false);
    }
}
